/*
 * Part of the ACID Project
 * Developed in 2011 by Morgan Taschuk
 */
package acid.spring.jdbc.services;

import acid.spring.GeneAliasService;
import acid.spring.db.GeneAlias;
import acid.spring.db.Organism;
import acid.spring.jdbc.repositories.GeneAliasRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author morgan
 */
@Service
public class JdbcGeneAliasService implements GeneAliasService
{

    @Autowired
    private GeneAliasRepository geneAliasRepository;

    @Override
    @Transactional(readOnly = true)
    public GeneAlias getGeneAliasById(int id)
    {
        return geneAliasRepository.getGeneAliasById(id);
    }
    
    @Override
    @Transactional(readOnly = true)
    public GeneAlias getGeneAliasByAlias(String s)
    {
        return geneAliasRepository.getGeneAliasByAlias(s);
    }

    @Override
    @Transactional
    public GeneAlias createGeneAlias(int id, String alias, Organism organism)
    {
        GeneAlias ga = new GeneAlias(id, alias, organism);
        return geneAliasRepository.saveGeneAlias(ga);
    }
}
